// /common/http.api.js
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// /app/businessUser/passwordLogin
	const passwordLogin = (params = {}) => vm.$u.get(`businessUser/passwordLogin`, params).then(res => {
		return res.data
	});
	const sendSMS = (params = {}) => vm.$u.get(`businessUser/sendSMS`, params).then(res => {
		return res.data
	});
	const telPhoneLogin = (params = {}) => vm.$u.get(`businessUser/telPhoneLogin`, params).then(res => {
		return res
	});
	const checkInvitationCode = (params = {}) => vm.$u.get(`businessUser/checkInvitationCode`, params).then(res => {
		return res.data
	});
	// 开启直播 
	const startLive = (params = {}) => vm.$u.get(`businessUser/startLive`, params).then(res => {
		return res.data
	});
	// 关闭直播
	const closeLive = (params = {}) => vm.$u.get(`businessUser/closeLive`, params).then(res => {
		return res.data
	});
	// 首页轮播图
	const getCarouselMapList = (params = {}) => vm.$u.get(`carouselMap/getCarouselMapList`, params).then(res => {
		return res.data
	});
	// 全部分类
	const getGoodsTypeList = (params = {}) => vm.$u.get(`goodsType/getGoodsTypeList`, params).then(res => {
		return res.data
	});
	// 商品详情
	const getGoodsById = (params = {}) => vm.$u.get(`goodsInfo/getGoodsById`, params).then(res => {
		return res.data
	});

	// 商品详情--规格
	const getGoodsAttr = (params = {}) => vm.$u.get(`goodsInfo/getGoodsAttr`, params).then(res => {
		return res.data
	});
	// 商品详情--收藏
	const addGoodsCollection = (params = {}) => vm.$u.get(`goodsCollection/addGoodsCollection`, params).then(
		res => {
			return res.data
		});
	// 添加地址
	const addReceivingAddress = (params = {}) => vm.$u.post(`receivingAddress/addReceivingAddress`, params).then(
		res => {
			return res.data
		});
	// 地址列表
	const getReceivingAddress = (params = {}) => vm.$u.get(`receivingAddress/getReceivingAddress`, params).then(
		res => {
			return res.data
		});
	// 地址列表-删除
	const delReceivingAddress = (params = {}) => vm.$u.get(`receivingAddress/delReceivingAddress`, params).then(
		res => {
			return res.data
		});
	// 地址列表-编辑
	const updateReceivingAddress = (params = {}) => vm.$u.post(`receivingAddress/updateReceivingAddress`, params)
		.then(
			res => {
				return res.data
			});

	// 商家-详情
	const appBusinessInfo = (params = {}) => vm.$u.get(`appBusiness/appBusinessInfo`, params)
		.then(
			res => {
				return res.data
			});
	// 个人信息
	const personalCenter = (params = {}) => vm.$u.get(`appUser/personalCenter`, params)
		.then(
			res => {
				return res.data
			});
	// 修改密码 GET /app/businessUser/passwordLogin
	const setPassword = (params = {}) => vm.$u.get(`appUser/setPassword`, params)
		.then(
			res => {
				return res.data
			});
	// 店铺-关注
	const followAppBusiness = (params = {}) => vm.$u.get(`appBusiness/followAppBusiness`, params)
		.then(
			res => {
				return res.data
			});
	// 商家入驻
	const addAppBusiness = (params = {}) => vm.$u.post(`appBusiness/addAppBusiness`, params)
		.then(
			res => {
				return res.data
			});
	// 积分
	const myIntegralDetails = (params = {}) => vm.$u.get(`appUser/myIntegralDetails`, params)
		.then(
			res => {
				return res.data
			});
	// 积分明细
	const myIntegralDetailsList = (params = {}) => vm.$u.get(`appUser/myIntegralDetailsList`, params)
		.then(
			res => {
				return res.data
			});
	// 更换手机号
	const replaceTelPhone = (params = {}) => vm.$u.get(`appUser/replaceTelPhone`, params)
		.then(
			res => {
				return res.data
			});
	// 公告
	const getSysNotice = (params = {}) => vm.$u.get(`sysNotice/getSysNotice`, params)
		.then(
			res => {
				return res.data
			});
	// 新增订单
	const addOrderInfo = (params = {}) => vm.$u.post(`orderInfo/addOrderInfo`, params)
		.then(
			res => {
				return res.data
			});
	// 支付宝
	const orderAliPay = (params = {}) => vm.$u.get(`orderInfo/orderAliPay`, params)
		.then(
			res => {
				return res.data
			});
	// 微信
	const orderWxPay = (params = {}) => vm.$u.get(`orderInfo/orderWxPay`, params)
		.then(
			res => {
				return res.data
			});

	// 找回密码
	const forgetPassword = (params = {}) => vm.$u.get(`appUser/forgetPassword`, params)
		.then(
			res => {
				return res.data
			});

	// 取消订单
	const cancellationOrder = (params = {}) => vm.$u.get(`orderInfo/cancellationOrder`, params)
		.then(
			res => {
				return res.data
			});
	// 转给商家
	const transferBusiness = (params = {}) => vm.$u.get(`orderInfo/transferBusiness`, params)
		.then(
			res => {
				return res.data
			});
	// 订单详情
	const getOrderInfoById = (params = {}) => vm.$u.get(`orderInfo/getOrderInfoById`, params)
		.then(
			res => {
				return res.data
			});
	// 确认收货
	const confirmReceipt = (params = {}) => vm.$u.get(`orderInfo/confirmReceipt`, params)
		.then(
			res => {
				return res.data
			});
	// 商品/订单评价
	const addGoodsComment = (params = {}) => vm.$u.post(`goodsComment/addGoodsComment`, params)
		.then(
			res => {
				return res.data
			});
	// 添加申请售后
	const addAfterSalesOrder = (params = {}) => vm.$u.post(`afterSalesOrder/addAfterSalesOrder`, params)
		.then(
			res => {
				return res.data
			});
	// 售后详情
	const getAfterSalesOrderInfo = (params = {}) => vm.$u.get(`afterSalesOrder/getAfterSalesOrderInfo`, params)
		.then(
			res => {
				return res.data
			});

	// 删除订单
	const delOrderInfoById = (params = {}) => vm.$u.get(`orderInfo/delOrderInfoById`, params)
		.then(
			res => {
				return res.data
			});
	// 修改头像
	const updateHandlImg = (params = {}) => vm.$u.get(`appUser/updateHandlImg`, params)
		.then(
			res => {
				return res.data
			});
	// 修改昵称
	const updateNickName = (params = {}) => vm.$u.get(`appUser/updateNickName`, params)
		.then(
			res => {
				return res.data
			});
	// 账户注销
	const accountCancellation = (params = {}) => vm.$u.get(`appUser/accountCancellation`, params)
		.then(
			res => {
				return res.data
			});
	// 消息列表 POST /app/appOneUserMessageBusinessBusiness/findMsgUserList
	const findMsgUserList = (params = {}) => vm.$u.post(`appOneUserMessageBusiness/findMsgUserList`, params)
		.then(
			res => {
				return res.data
			});
	// 发送消息
	const send = (params = {}) => vm.$u.post(`appOneUserMessageBusiness/send`, params)
		.then(
			res => {
				return res.data
			});

	const findNewMsg = (params = {}) => vm.$u.get(`appOneUserMessageBusiness/findNewMsg`, params)
		.then(
			res => {
				return res.data
			});
	const findMsgPage = (params = {}) => vm.$u.get(`appOneUserMessageBusiness/findMsgPage`, params)
		.then(
			res => {
				return res.data
			});
	const getUserInfoById = (params = {}) => vm.$u.get(`appUser/getUserInfoById`, params)
		.then(
			res => {
				return res.data
			});
	vm.$u.api = {
		getUserInfoById,
		startLive,
		closeLive,
		findMsgPage,
		findNewMsg,
		send,
		findMsgUserList,
		accountCancellation,
		updateNickName,
		updateHandlImg,
		delOrderInfoById,
		getAfterSalesOrderInfo,
		addAfterSalesOrder,
		addGoodsComment,
		confirmReceipt,
		getOrderInfoById,
		transferBusiness,
		cancellationOrder,
		forgetPassword,
		orderAliPay,
		orderWxPay,
		addOrderInfo,
		getSysNotice,
		replaceTelPhone,
		myIntegralDetailsList,
		myIntegralDetails,
		addAppBusiness,
		followAppBusiness,
		setPassword,
		personalCenter,
		appBusinessInfo,
		updateReceivingAddress,
		delReceivingAddress,
		getReceivingAddress,
		addReceivingAddress,
		addGoodsCollection,
		getGoodsAttr,
		getGoodsById,
		getGoodsTypeList,
		getCarouselMapList,
		checkInvitationCode,
		telPhoneLogin,
		sendSMS,
		passwordLogin,
	};
}
export default {
	install

}
